﻿using System.Collections.Generic;
using System;

namespace BasecampSync
{
    /// <summary>
    /// Represents a basecamp project
    /// </summary>
    struct Project
    {
        private uint myId;
        private string myName;
        private List<Milestone> myMilestones;

        public uint Id
        {
            get { return myId; }
            set { myId = value; }
        }

        public string Name
        {
            get { return myName; }
            set { myName = value; }
        }

        public List<Milestone> Milestones
        {
            get { return myMilestones; }
            set { myMilestones = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Milestone object, or null if not found</returns>
        public Milestone Contains(uint id)
        {
            foreach (Milestone curMilestone in this.Milestones)
            {
                if (curMilestone.Id == id)
                {
                    return curMilestone;
                }
            }

            // Not found
            throw new ArgumentException();
        }
    }

    struct TodoList
    {
        private uint myId;
        private string myName;
        private string myDescription;
        List<TodoItem> myTodoItems;

        public uint Id
        {
            get { return myId; }
            set { myId = value; }
        }

        public string Name
        {
            get { return myName; }
            set { myName = value; }
        }

        public string Description
        {
            get { return myDescription; }
            set { myDescription = value; }
        }

        public List<TodoItem> TodoItems
        {
            get { return myTodoItems; }
            set { myTodoItems = value; }
        }

        /// <summary>
        /// Tests if the given list contains an item with "id"
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Contains(UInt32 id)
        {
            foreach (TodoItem curItem in myTodoItems)
            {
                if (curItem.Id == id)
                {
                    return true;
                }
            }

            return false;
        }
    }

    struct TodoItem
    {
        private UInt32 myId;
        private string myContent;
        private DateTime myCreated;
        private Person myCreator;
        private bool myCompleted;

        public UInt32 Id
        {
            get { return myId; }
            set { myId = value; }
        }

        public string Content
        {
            get { return myContent; }
            set { myContent = value; }
        }

        public DateTime Created
        {
            get { return myCreated; }
            set { myCreated = value; }
        }

        public Person Creator
        {
            get { return myCreator; }
            set { myCreator = value; }
        }

        public bool Completed
        {
            get { return myCompleted; }
            set { myCompleted = value; }
        }
    }

    struct Person
    {
        private UInt32 myId;
        private string myEmail;
        private string myFirstName;
        private string myLastName;

        public UInt32 Id
        {
            get { return myId; }
            set { myId = value; }
        }

        public string Email
        {
            get { return myEmail; }
            set { myEmail = value; }
        }

        public string FirstName
        {
            get { return myFirstName; }
            set { myFirstName = value; }
        }

        public string LastName
        {
            get { return myLastName; }
            set { myLastName = value; }
        }
    }

    struct Milestone
    {
        uint myId;
        bool myCompleted;
        DateTime myCreated;
        DateTime myDeadline;
        uint myProjectId;
        string myTitle;

        public uint Id
        {
            get { return myId; }
            set { myId = value; }
        }

        public bool Completed
        {
            get { return myCompleted; }
            set { myCompleted = value; }
        }

        public DateTime Deadline
        {
            get { return myDeadline; }
            set { myDeadline = value; }
        }

        public DateTime Created
        {
            get { return myCreated; }
            set { myCreated = value; }
        }

        public uint ProjectId
        {
            get { return myProjectId; }
            set { myProjectId = value; }
        }

        public string Title
        {
            get { return myTitle; }
            set { myTitle = value; }
        }
    }
}